import 'package:dio/dio.dart';
import 'package:flutter/material.dart';

class ReqNews {
  final Dio _dio;

  ReqNews(this._dio);
  // 新闻点赞
  addNewsLikes({
    @required String newsId,
  }) {
    return _dio.post('/news/givelike', data: {
      "news_id": newsId,
    });
  }

  // 新闻取消点赞
  cancelNewsLikes({
    @required String newsId,
  }) {
    return _dio.post('/news/unlike', data: {
      "news_id": newsId,
    });
  }

  //新闻详情
  reqNewsDetails({String id}) {
    return _dio.get('/news/detail', queryParameters: {
      "id": id,
    });
  }

  //是否收藏
  reqNewsIsCollect({int objType, String objId}) {
    return _dio.get('/user/isCollect', queryParameters: {
      "obj_type": objType,
      "obj_id": objId,
    });
  }

  // 收藏
  addNewsCollect({
    @required String objId,
    @required int objType,
  }) {
    return _dio
        .post('/user/collect', data: {"obj_id": objId, "obj_type": objType});
  }

  // 取消收藏
  cancelNewsCollect({
    @required String objId,
    @required int objType,
  }) {
    return _dio.get('/user/uncollect',
        queryParameters: {"obj_id": objId, "obj_type": objType});
  }
}
